package com.model;

import lombok.Data;
import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * @author 10377
 */
@Data
public class Number implements WritableComparable<Number> {
    private Integer id;
    private Integer number;

    @Override
    public int compareTo(Number o) {
        return Integer.compare(this.number,o.number);
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeInt(id);
        dataOutput.writeInt(number);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.id = dataInput.readInt();
        this.number = dataInput.readInt();
    }

    @Override
    public String toString() {
        return id + "\t" + number;
    }
}
